package main

import (
	"fmt"
	"os"
)

/*
./robobloqSerial 2
*/
func GetCommOsInfo() {
	var argsLen int = len(os.Args)
	ostype := "0"
	if argsLen > 1 {
		ostype = os.Args[1]
	}
	if ostype == "11" {
		SY.WebSocketPort = os.Args[2]
		SY.HTTPPort = os.Args[3]
		if argsLen > 4 {
			SY.IDE = os.Args[4]
		}
	}
	if ostype == "2" {
		SY.HTTPPort = os.Args[2]
		if argsLen > 3 {
			SY.IDE = os.Args[3]
		}
	}
	if ostype == "1" {
		SY.WebSocketPort = os.Args[2]
		if argsLen > 3 {
			SY.IDE = os.Args[3]
		}
	}
}

func runMain() {
	GetCommOsInfo()
	ar, os := GetOsInfo()
	sylog := "\nversion:" + SY.Version
	sylog = sylog + "\nRobobloq.com \nGOARCH=" + ar + " GOOS=" + os + "\n"
	fmt.Printf(sylog)
	//if SY.OsType == "2" {
	lg1 := "server:http://localhost:" + SY.HTTPPort + "/p\n"
	fmt.Printf(lg1)
	go HTTPServerRun()
	//} else {
	lg := "server:ws://localhost:" + SY.WebSocketPort + "/ws\n"
	fmt.Printf(lg)
	webSocketRun()
	//}
}
